class Person {
  //声明成员属性,默认情况下是public
  name: string;
  protected age: number;

  //默认调用这个构造函数
  constructor(name: string, age: number) {
    this.name = name;
    this.age = age;
  }
  //私有属性，类的外部访问不了
  private eating() {
    console.log("吃东西", this.age);
  }
}
const p1 = new Person("why", 12);
const p2 = new Person("kobe", 16);

// 属性“age”受保护，只能在类“Person”及其子类中访问。
// console.log(p1.name, p2.age);

//protected类的外部可以使用
class Student extends Person {
  studying() {
    console.log(this.age);
  }
   test(){
    console.log(this.test)
  }
}
 
export {};
